float fvalue1;
uniform extern texture imageTexture;
sampler sourceMap = sampler_state
{
   Texture = <imageTexture>;
};
struct PS_INPUT 
{
   float2 Texcoord : TEXCOORD0;
};
float4 Pixel_Shader_ps_main( PS_INPUT Input ) : COLOR0
{
   float H = fvalue1 * 100;
   float V;
   float S;
   float hi;
   float f;
   float p;
   float q;
   float t;
   float sourceR = tex2D ( sourceMap, Input.Texcoord ).x;
   float sourceG = tex2D ( sourceMap, Input.Texcoord ).y;
   float sourceB = tex2D ( sourceMap, Input.Texcoord ).z;
   float sourceA = tex2D ( sourceMap, Input.Texcoord ).w;
   float MAX = max(max(sourceR, sourceG), sourceB);
   float MIN = min(min(sourceR, sourceG), sourceB);
   
   if(MAX == 0)
   {
      S = 0;
   }
   else
   {
      S = (MAX - MIN) / MAX;
   }
   V = MAX;
   hi = abs( H / 60 );
   int hi2 = hi;
   hi = hi2;
   f = H / 60 - hi;
   p = V * (1 - S);
   q = V * (1 - S * f);
   t = V * (1 - S * (1 - f));
   if(hi == 0 || hi == 6)
   {
      return float4(V, t, p, sourceA);
   }
   else if(hi == 1)
   {
      return float4(q, V, p, sourceA);
   }
   else if(hi == 2)
   {
      return float4(p, V, t, sourceA);
   }
   else if(hi == 3)
   {
      return float4(p, q, V, sourceA);
   }
   else if(hi == 4)
   {
      return float4(t, p, V, sourceA);
   }
   else
   {
      return float4(V, p, q, sourceA);
   }
}

technique HueModifier
{
   pass Pass_0
   {
      PixelShader = compile ps_2_0 Pixel_Shader_ps_main();
   }
}